package kalendersystem;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;

import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.ListModel;

import javax.swing.WindowConstants;
import javax.swing.SwingUtilities;

public class ReserverRom extends javax.swing.JFrame {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private JList romList;
	private JButton reserverButton, endreButton, avbrytButton;
	private JLabel sluttLabel, startLabel, datoLabel;
	private JTextField sluttField, datoField, startField;
	private JTextArea beskrivelseArea;
	private JScrollPane romListScroll, beskrivelseAreaScroll;
	private JLabel headerLabel;

	public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				ReserverRom inst = new ReserverRom("Reserver rom");
				inst.setLocationRelativeTo(null);
				inst.setVisible(true);
			}
		});
	}
	
	public ReserverRom(String str) {
		super(str);
		initGUI();
	}
	
	private void initGUI() {
		try {
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			setLayout(new GridBagLayout());
			GridBagConstraints c = new GridBagConstraints();
			c.insets = new Insets(2, 2, 2, 2);
			c.anchor = GridBagConstraints.WEST;
			{
				headerLabel = new JLabel("Velg et ledig rom:");
				c.gridx = 1;
				c.gridy = 0;
				headerLabel.setFont(new Font("arial", Font.BOLD, 16));
				getContentPane().add(headerLabel, c);
			}
			{
				ListModel romListModel = 
					new DefaultComboBoxModel(
							new String[] { });
				romList = new JList();
				romListScroll = new JScrollPane(romList);
				romListScroll.setPreferredSize(new Dimension(150, 100));
				c.gridx = 1;
				c.gridy = 1;
				c.gridheight = 2;
				c.fill = c.BOTH;
				getContentPane().add(romListScroll, c);
				romList.setModel(romListModel);
				romList.setLayout(null);
				c.gridheight = 1;
			}
			{
				beskrivelseArea = new JTextArea(10, 25);
				beskrivelseAreaScroll = new JScrollPane(beskrivelseArea);
				beskrivelseArea.setLineWrap(true);
				c.gridx = 2;
				c.gridy = 2;
				c.gridwidth = 7;
				getContentPane().add(beskrivelseAreaScroll, c);
				c.gridwidth = 1;
			}
			{
				datoField = new JTextField(6);
				c.gridx = 3;
				c.gridy = 1;
				getContentPane().add(datoField, c);
			}
			{
				startField = new JTextField(3);
				c.gridx = 5;
				c.gridy = 1;
				getContentPane().add(startField, c);
			}
			{
				sluttField = new JTextField(3);
				c.gridx = 7;
				c.gridy = 1;
				getContentPane().add(sluttField, c);
				c.fill = c.NONE;
			}
			{
				datoLabel = new JLabel();
				c.gridx = 2;
				c.gridy = 1;
				getContentPane().add(datoLabel, c);
				datoLabel.setText("Dato:");
			}
			{
				startLabel = new JLabel();
				c.gridx = 4;
				c.gridy = 1;
				getContentPane().add(startLabel, c);
				startLabel.setText("Start:");
			}
			{
				sluttLabel = new JLabel();
				c.gridx = 6;
				c.gridy = 1;
				getContentPane().add(sluttLabel, c);
				sluttLabel.setText("Slutt:");
			}
			{
				reserverButton = new JButton();
				c.gridx = 7;
				c.gridy = 3;
				c.gridwidth = 2;
				c.anchor = GridBagConstraints.EAST;
				c.fill = c.BOTH;
				getContentPane().add(reserverButton, c);
				reserverButton.setText("Reserver rom");
				c.anchor = GridBagConstraints.WEST;
				c.gridwidth = 1;
			}
			{
				avbrytButton = new JButton();
				c.gridx = 5;
				c.gridy = 3;
				c.gridwidth = 2;
				getContentPane().add(avbrytButton, c);
				avbrytButton.setText("Avbryt");
				c.gridwidth = 1;
			}
			{
				endreButton = new JButton();
				c.gridx = 8;
				c.gridy = 1;
				c.anchor = GridBagConstraints.EAST;
				getContentPane().add(endreButton, c);
				endreButton.setText("Endre");
			}
			pack();
			setSize(520, 300);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}
